import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/global.dart';
import 'package:flutter_changdian_football/routers/app_pages.dart';
import 'package:flutter_changdian_football/widget/scroll/no_shadow_scroll_behavior.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:get/route_manager.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';


void main()=> Global.init().then((value) => runApp(const App()));

class App extends StatelessWidget {
  const App({super.key});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        FocusScope.of(Get.context!).requestFocus(FocusNode());
      },
      child: GetMaterialApp(
        title: '畅点足球',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        debugShowCheckedModeBanner: false,
        builder: EasyLoading.init(
          builder: (context, child) {
            return MediaQuery(
              // 设置文字大小不随系统设置改变
              data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
              child: ScrollConfiguration(
                behavior: NoShadowScrollBehavior(),
                child: child ?? const Material(),
              ),
            );
          }
        ),
        initialRoute: AppPages.initial,
        localizationsDelegates: const [
          //是Flutter的一个本地化委托，用于提供Material组件库的本地化支持
          GlobalMaterialLocalizations.delegate,
          //用于提供通用部件（Widgets）的本地化支持
          GlobalWidgetsLocalizations.delegate,
          //用于提供Cupertino风格的组件的本地化支持
          GlobalCupertinoLocalizations.delegate,
          PickerLocalizationsDelegate.delegate,
        ],
        supportedLocales: const [
          // 支持的语言和地区
          Locale('zh', 'CN'),
        ],
        getPages: AppPages.routes,
      ),
    );
  }
}
